﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Clinica_Frba.Login
{
    public partial class Principal : Form
    {
        public Principal()
        {
            InitializeComponent();
        }
        public Principal(string id_rol)
        {
            InitializeComponent();
            SqlConnection myConnection = new SqlConnection(publico.ConnectionString);
            myConnection.Open();
            SqlCommand consulta = new SqlCommand("SELECT FUNCIONALIDAD.ID_FUNC,DESC_FUNC FROM ROL_FUNCIONALIDAD LEFT JOIN FUNCIONALIDAD ON FUNCIONALIDAD.ID_FUNC=ROL_FUNCIONALIDAD.ID_FUNC WHERE ID_ROL="+id_rol, myConnection);
            SqlDataReader executeCMD = consulta.ExecuteReader();
            while (executeCMD.Read()){
                if (executeCMD.GetInt32(0)==1) {
                    button1.Visible = true;
                }
                if (executeCMD.GetInt32(0) == 2)
                {
                    button2.Visible = true;
                }
                if (executeCMD.GetInt32(0) == 3)
                {
                    button3.Visible = true;
                }
                if (executeCMD.GetInt32(0) == 4)
                {
                    button4.Visible = true;
                }
                if (executeCMD.GetInt32(0) == 6)
                {
                    button5.Visible = true;
                }
                if (executeCMD.GetInt32(0) == 7)
                {
                    button6.Visible = true;
                }
                if (executeCMD.GetInt32(0) == 8)
                {
                    button7.Visible = true;
                }
                if (executeCMD.GetInt32(0) == 9)
                {
                    button8.Visible = true;
                }
                if (executeCMD.GetInt32(0) == 10)
                {
                    button9.Visible = true;
                }
                if (executeCMD.GetInt32(0) == 11)
                {
                    button10.Visible = true;
                }
                if (executeCMD.GetInt32(0) == 12)
                {
                    button11.Visible = true;
                }
                if (executeCMD.GetInt32(0) == 13)
                {
                    button12.Visible = true;
                }
                if (executeCMD.GetInt32(0) == 14)
                {
                    informesButton.Visible = true;
                }
            }

        }
        private void Principal_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Clinica_Frba.AbmdeRol.ABMRol f = new Clinica_Frba.AbmdeRol.ABMRol();
            f.Show();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Hide();
            FormABMAfiliados abmAfiliados = new FormABMAfiliados();
            abmAfiliados.ShowDialog();
            Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
        
        }

        private void button4_Click(object sender, EventArgs e)
        {
            Clinica_Frba.AbmdeProfesional.ABMProfesional f = new Clinica_Frba.AbmdeProfesional.ABMProfesional();
            f.Show();
        }


        private void informesButton_Click(object sender, EventArgs e)
        {
            Clinica_Frba.NewFolder9.ListadoEstadisticoForm form = new Clinica_Frba.NewFolder9.ListadoEstadisticoForm();
            form.Show();
        }

        private void button6_Click(object sender, EventArgs e)
        {
            Clinica_Frba.RegistrarAgenda.elegirprof form = new Clinica_Frba.RegistrarAgenda.elegirprof();
            form.Show();
        }    

        private void button12_Click(object sender, EventArgs e)
        {
            //REAL
            Clinica_Frba.Generar_Receta.ListadoRecetas form = new Clinica_Frba.Generar_Receta.ListadoRecetas();
            form.ShowDialog(this);

            //PARA PRUEBAS
            //Clinica_Frba.NewFolder8.Form1 form = new Clinica_Frba.NewFolder8.Form1();
            //form.Show();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            Hide();
            FormBuscarProfesionalParaTurno abmAfiliados = new FormBuscarProfesionalParaTurno();
            abmAfiliados.ShowDialog();
            Show();     
        }

        private void button7_Click(object sender, EventArgs e)
        {
            Clinica_Frba.CompradeBono.Compra form = new Clinica_Frba.CompradeBono.Compra();
            form.Show();
        }

        private void button9_Click(object sender, EventArgs e)
        {
            Clinica_Frba.Registro_de_LLegada.RegistroLlegada form = new Clinica_Frba.Registro_de_LLegada.RegistroLlegada();
            form.Show();
        }

        private void button11_Click(object sender, EventArgs e)
        {
            Hide();
            FormSeleccionarCancelador form = new FormSeleccionarCancelador();
            form.ShowDialog();
            Show();
        }

        private void button10_Click(object sender, EventArgs e)
        {
            Clinica_Frba.Registro_Resultado_Atencion.Elegiratn form = new Clinica_Frba.Registro_Resultado_Atencion.Elegiratn();
            form.Show();
        }
    }
}
